package com.lcredu.web.viewresolver;

import org.springframework.stereotype.Component;
import org.springframework.web.servlet.view.AbstractView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

/**
 * @author 黎长容
 * @date 2025-07-21 18:30
 */
@Component(value = "lcrView")
public class MyView extends AbstractView {
    /*
    黎长容知识01
    总结一下创建自定义视图解析的流程
        1.写前端访问页面
        2.写自己的handle GoodsHandler
        3.写自定义视图解析器 MyView 继承与 AbstractView
        4.在spring配置文件上面配置自定义视图解析器bean--
            <bean class="org.springframework.web.servlet.view.BeanNameViewResolver" id="beanNameViewResolver">
                <property name="order" value="99"/>
            </bean>
        5.注意: 写自己的handle GoodsHandler 要返回的视图是自定义视图解析器的lcrView  @Component(value = "lcrView")
     */
    @Override
    protected void renderMergedOutputModel(Map<String, Object> map, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
        System.out.println("----renderMergedOutputModel()----");
        httpServletRequest.getRequestDispatcher("/WEB-INF/pages/my_view.jsp").forward(httpServletRequest, httpServletResponse);
    }
    
}
